package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	public class TestMove extends Sprite
	{
		private		var		_ball:Sprite = null;
		private		var		_targetPt:Point = null;
		private		var		_eraseSpeed:Number = 0.1;
		
		private		var		_vx:Number = 0.0;
		private		var		_vy:Number = 0.0;
		
		public function TestMove()
		{
			super();
			
			this._ball = new Sprite();
			this._ball.graphics.beginFill(0xff0000);
			this._ball.graphics.drawCircle(50,50, 30);
			this._ball.graphics.endFill();
			
			this._targetPt = new Point(200, 100);
			this.addChild(this._ball);
			this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		
		public	function	onEnterFrame(evt:Event):void{
//			this._targetPt.x = this.mouseX;
//			this._targetPt.y = this.mouseY;
//			
			var cx:Number = (this._targetPt.x - this._ball.x)*this._eraseSpeed;
			var cy:Number = (this._targetPt.y - this._ball.y)*this._eraseSpeed;
			var distance:Number = Math.sqrt(cx*cx + cy*cy);
//			if (distance < 0.1){
//				this._ball.x = this._targetPt.x;
//				this._ball.y = this._targetPt.y;
//				return;
//			}
			this._vx += cx;
			this._vy += cy;

			
			this._ball.x += this._vx;
			this._ball.y += this._vy;
			
			this._vx *= 0.95;
			this._vy *= 0.95;
		}
	}
}